#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import asyncio
import aiohttp
import json

async def debug_api_response():
    """调试API返回结构"""
    print("🔍 调试API返回结构...")
    
    request_data = {
        "equipment": "网络安全设备",
        "sceneDesc": "数据泄露应急演练",
        "plan": {
            "事件类型": "网络安全事件",
            "响应级别": "一级",
            "处置流程": "立即响应",
            "应急措施": "隔离网络、备份数据、通知相关人员"
        },
        "scriptNode": [
            {
                "nodeOrder": 1,
                "nodeName": "发现事件",
                "nodeType": "对话",
                "children": []
            },
            {
                "nodeOrder": 2,
                "nodeName": "应急响应",
                "nodeType": "操作",
                "children": []
            }
        ]
    }
    
    async with aiohttp.ClientSession() as session:
        async with session.post(
            "http://localhost:8085/api/v1/generate_drill_script",
            json=request_data,
            headers={"Content-Type": "application/json"}
        ) as response:
            result = await response.json()
            
            print(f"🔍 完整API返回结构:")
            print(json.dumps(result, ensure_ascii=False, indent=2))
            
            print(f"\n🔍 字段分析:")
            print(f"   - 根字段: {list(result.keys())}")
            
            for key, value in result.items():
                if isinstance(value, list):
                    print(f"   - {key}: 数组，长度 {len(value)}")
                elif isinstance(value, dict):
                    print(f"   - {key}: 字典，字段 {list(value.keys())}")
                else:
                    print(f"   - {key}: {type(value).__name__}, 值 {value}")
            
            return result

if __name__ == "__main__":
    asyncio.run(debug_api_response()) 